//
//  XJLVerifyCodeViewController.m
//  XJL_WeChat
//
//  Created by XJL on 16/7/31.
//  Copyright © 2016年 Xujiali. All rights reserved.
//

#import "XJLVerifyCodeViewController.h"
#import <SMS_SDK/SMSSDK.h>
#import "XJLRegisterPwdViewController.h"


@interface XJLVerifyCodeViewController ()
@property (weak, nonatomic) IBOutlet UILabel *telNumberLable;
@property (weak, nonatomic) IBOutlet UITextField *verifyCodeField;

@end

@implementation XJLVerifyCodeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    //显示电话号码
    NSString *text = [NSString stringWithFormat:@"手机号码 %@ %@",_code,_tel];
    self.telNumberLable.text = text;
}

- (IBAction)submitAction {
    
    //验证码正确才能进入密码设置界面
    [SVProgressHUD showWithStatus:@"验证中..."];
    [SMSSDK commitVerificationCode:self.verifyCodeField.text phoneNumber:self.tel zone:self.code result:^(NSError *error) {
//        error = nil;
        if (error) {
            [SVProgressHUD showErrorWithStatus:error.description];
        }else{
            [SVProgressHUD dismiss];
            XJLRegisterPwdViewController *regPwdVc = [[XJLRegisterPwdViewController alloc]init];
            regPwdVc.tel = self.tel;
            regPwdVc.code = self.code;
            
            [self presentViewController:regPwdVc animated:YES completion:nil];
        }
    }];
    
}

- (IBAction)back {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
